package com.xiaomazi.video.controller;

import com.xiaomazi.common.utils.R;
import com.xiaomazi.video.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @program: llxy-parent
 * @description: 视频前端控制器
 * @author: 小马子
 * @create: 2023-02-19 20:16
 **/
@RestController
@RequestMapping("/eduvod/video")
public class VideoController {

    @Autowired
    private VideoService videoService;

    @PostMapping("/uploadAlyiVideo")
    public R uploadAlyiVideo(MultipartFile file){
        return videoService.uploadAlyiVideo(file);
    }

    @DeleteMapping("/removeAlyVideo/{id}")
    public R removeAlyVideo(@PathVariable String id){
        return videoService.removeAlyVideo(id);
    }

    @DeleteMapping("/deleteBatch")
    public R deleteBatch(@RequestParam("videoIdList") List<String> videoIdList) {
        return videoService.removeMoreAlyVideo(videoIdList);
    }

    @GetMapping("/getPlayAuth/{vid}")
    public R getPlayAuth(@PathVariable String vid){
        return videoService.getPlayAuth(vid);
    }

}
